<<<<<<< HEAD
import { createRouter,  createWebHashHistory } from 'vue-router'
import {generateRoutes} from './addRouter'
import {useMenu} from '../stores/Menu'
const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path:'/',
      redirect:'/dashboard'
    },
    {
      path: '/',
      name: 'home',
      component: () => import('../views/Home.vue'),
      children:[
         {
          path:'/dashboard',
          name:'dashboard',
          meta:{
            title:'系统首页',
            
          },
          component:()=>import('../views/system/paramInfo.vue')  
        },
        {
          path:'/system/paramInfo',
          name:'paramInfo',
          meta:{
            title:'参数信息',
          },
          component:()=>import('../views/system/paramInfo.vue')  
        },
        {
          path:'/system/config',
          name:'config',
          meta:{
            title:'配置信息',
          
          },
          component:()=>import('../views/system/config.vue')  
        },
        {
          path:'/system/backup',
          name:'backup',
          meta:{
            title:'数据库备份',
          
          },
          component:()=>import('../views/system/backup.vue')  
        },
        {
          path:'/user/adminList',
          name:'adminList',
          meta:{
            title:'管理员管理',
           
          },
          component:()=>import('../views/user/AdminList.vue')  
        },
        {
            path:'/user/stuList',
            name:'stuList',
            meta:{
              title:'用户管理',
             
            },
            component:()=>import('../views/user/StudentList1.vue')
        },
        {
          path:'/user/teacherList',
          name:'teacherList',
          meta:{
            title:'教师管理',
           
          },
          component:()=>import('../views/user/TeacherList.vue')
          },
          {
            path:'/user/advisorList',
            name:'advisorList',
            meta:{
              title:'咨询师管理',
             
            },
            component:()=>import('../views/user/AdvisorList.vue')
        },

        {
          path:'/privilege/userGroup',
          name:'userGroup',
          meta:{
            title:'用户组管理',
            
          },
          component:()=>import('../views/privilege/UserGroup.vue')  
        },
        {
          path:'/privilege/roleList',
          name:'roleList',
          meta:{
            title:'角色管理',
           
          },
          component:()=>import('../views/privilege/RoleList.vue')  
        },
        {
          path:'/privilege/rolePriv',
          name:'rolePriv',
          meta:{
            title:'角色权限',
           
          },
          component:()=>import('../views/privilege/RolePriv.vue')  
        },
        {
          path:'/privilege/menuList',
          name:'menuList',
          meta:{
            title:'菜单管理',
            
          },
          component:()=>import('../views/privilege/MenuList.vue')  
        },
        {
          path:'/privilege/menuAction',
          name:'menuAction',
          meta:{
            title:'菜单行为',
            
          },
          component:()=>import('../views/privilege/MenuAction.vue')  
        },
        {
          path:'/privilege/actionList',
          name:'actionList',
          meta:{
            title:'行为管理',
          
          },
          component:()=>import('../views/privilege/actionList.vue')  
        },
        {
          path:'/clazz/major',
          name:'major',
          meta:{
            title:'专业方向',
            
          },
          component:()=>import('../views/clazz/Major.vue')  
        },
        {
          path:'/clazz/clazzList',
          name:'clazzList',
          meta:{
            title:'班级列表',
            
          },
          component:()=>import('../views/clazz/ClazzList.vue')  
        },
        {
          path:'/clazz/question',
          name:'question',
          meta:{
            title:'班级问题',
            
          },
          component:()=>import('../views/clazz/Question.vue')  
        },
        {
          path:'/clazz/homework',
          name:'homework',
          meta:{
            title:'班级问题',
           
          },
          component:()=>import('../views/clazz/Homework.vue')  
        },
        {
          path:'/clazz/studyProcess',
          name:'studyProcess',
          meta:{
            title:'班级问题',
            
          },
          component:()=>import('../views/clazz/StudyProcess.vue')  
        },
        
        {
          path:'/notice/noticeList',
          name:'noticeList',
          meta:{
            title:'公告管理',
            
          },
          component:()=>import('../views/notice/NoticeList.vue')  
        },
        {
          path:'/notice/newsList',
          name:'newsList',
          meta:{
            title:'新闻咨询',
            
          },
          component:()=>import('../views/notice/NewsList.vue')  
        },
        
        {
          path:'/log/list',
          name:'logList',
          meta:{
            title:'日志列表',
           
          },
          component:()=>import('../views/log/LogList.vue')  
        },
        {
          path:'/organization/branchList',
          name:'branchList',
          meta:{
            title:'分支机构',
           
          },
          component:()=>import('../views/organization/BranchList.vue')  
        },
        {
          path:'/organization/orgList',
          name:'orgList',
          meta:{
            title:'机构列表',
            
          },
          component:()=>import('../views/organization/OrgList.vue')  
        },
 
        {
          path:'/:path(.*)',
          name:'notFound',
          meta:{
            title:'没有权限'
          },
          component: () => import(/* webpackChunkName: "403" */ '../views/NoPrivilege.vue'),
         },
        
      ]
      
    },
    {
      path: '/login',
      name: 'login',
      meta: {
          title: '登录',
      },
      component: () => import(/* webpackChunkName: "login" */ '../views/Login.vue'),
      
  },

  
  {
      path: '/403',
      name: '403',
      meta: {
          title: '没有权限',
      },
      component: () => import(/* webpackChunkName: "403" */ '../views/403.vue'),
  },
  ]
})

// 检查是否存在于免登陆白名单
/* function inWhiteList(toPath) {
    const whiteList = ['/login', '/403']
    const path = whiteList.find((value) => {
        // 使用正则匹配
        const reg = new RegExp('^' + value)
        return reg.test(toPath)
    })
    return !!path
} */

router.beforeEach((to, from, next) => {
  console.group('%c%s', 'color:blue', `${new Date().getTime()}  ${to.path} 的全局前置守卫----------`)
    console.log('所有活跃的路由记录列表', router.getRoutes())
    console.groupEnd()
  document.title = `乐码在线智慧平台 - ${to.meta.title}`;
  const role = localStorage.getItem('ms_username');
  let token  = localStorage.getItem('token')

  console.log("to::",to,"from:",from)
  if (!role && to.path !== '/login') {
      next('/login');
  } else {
        //说明已经登录
      /*   console.log("登录之后。。。")
      let menuList = useMenu().menuList
      console.log(menuList+'=====')`
      generateRoutes(menuList) */
      next();
  }
});

=======
import {createRouter, createWebHistory} from 'vue-router'
import HomeView from '../views/Home.vue'
import menus from './menu2'

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        // 基础路由
        {
            path:"/",
            redirect:"/login"
        },
         {
            path: '/login',
            name: 'login',
            component: () => import('../views/Login.vue')
        },
        {
            path: '/register',
            name: 'register',
            component: () => import('../views/Register.vue')
        },
        {
            path: '/home',
            name: 'home',
            component: HomeView,
            children:menus
          /*   children: [

                {
                    path: "/dashboard",
                    name: "Dashboard",
                    meta: {title: "首页", icon: "HomeFilled", top: true},
                    component: () => import('@/views/Dashboard/Dashboard.vue')
                },

                {
                    path: "/memberCenter",
                    name: "MemberCenter",
                    meta: {
                        title: "会员管理",
                        icon: "User",
                        top: true
                    },
                    children: [
                        {
                            path: "member",
                            name: "Member",
                            meta: {
                                title: "会员",
                                icon: "UserFilled"
                            },
                            component: () => import('@/views/MemberCenter/Member.vue')
                        },
                        {
                            path: "memberCard",
                            name: "MemberCard",
                            meta: {
                                title: "会员卡",
                                icon: "Postcard"
                            },
                            component: () => import('@/views/MemberCenter/MemberCard.vue')
                        },
                        {
                            path: "memberBind",
                            name: "MemberBind",
                            meta: {
                                title: "会员绑定",
                                icon: "Postcard"
                            },
                            component: () => import('@/views/MemberCenter/MemberBind.vue')
                        }
                    ]
                },
                {
                    path: "/course",
                    name: "Course",
                    meta: {
                        title: "团课管理",
                        icon: "Grid",
                        top: true
                    },
                    children: [
                        {
                            path: "courseList",
                            name: "CourseList",
                            meta: {
                                title: "团课课程",
                                icon: "List"
                            },
                            component: () => import('@/views/Course/CourseList.vue')
                        },
                        {
                            path: "courseSchedule",
                            name: "CourseSchedule",
                            meta: {
                                title: "团课课表",
                                icon: "Calendar"
                            },
                            component: () => import('@/views/Course/CourseSchedule.vue')
                        },
                        {
                            path: "courseReservation",
                            name: "CourseReservation",
                            meta: {
                                title: "团课预约设置",
                                icon: "Setting"
                            },
                            component: () => import('@/views/Course/CourseReservation.vue')
                        }
                    ]
                },
                {
                    path: "/teacher",
                    name: "Teacher",
                    meta: {
                        title: "老师管理",
                        icon: "Avatar",
                        top: true
                    },
                    component: () => import('@/views/Teacher/Teacher.vue')
                },
                {
                    path: "/statistics",
                    name: "statistics",
                    meta: {
                        title: "数据统计",
                        icon: "TrendCharts",
                        top: true
                    },
                    children: [
                        {
                            path: "cardListStat",
                            name: "CardListStat",
                            meta: {
                                title: "会员卡统计",
                                icon: "PieChart"
                            },
                            component: () => import('@/views/statistics/CardListStat.vue')
                        },
                        {
                            path: "cardCostStat",
                            name: "CardCostStat",
                            meta: {
                                title: "收费统计",
                                icon: "Histogram"
                            },
                            component: () => import('@/views/statistics/CardCostStat.vue')
                        },
                        {
                            path: "classCostStat",
                            name: "ClassCostStat",
                            meta: {
                                title: "消课统计",
                                icon: "Histogram"
                            },
                            component: () => import('@/views/statistics/ClassCostStat.vue')
                        },
                        {
                            path: "classHourStat",
                            name: "ClassHourStat",
                            meta: {
                                title: "总课次统计",
                                icon: "Histogram"
                            },
                            component: () => import('@/views/statistics/ClassHourStat.vue')
                        },
                        {
                            path: "memberNumStat",
                            name: "MemberNumStat",
                            meta: {
                                title: "新增与流失统计",
                                icon: "Histogram"
                            },
                            component: () => import('@/views/statistics/MemberNumStat.vue')
                        }
                    ]
                },
                {
                    path: "/profile",
                    name: "profile",
                    meta: {
                        "title": "个人中心",
                        "icon": null,
                        "top": false
                    },
                    children: [
                        {
                            path: "modifyPwd",
                            name: "ModifyPwd",
                            meta: {
                                title: "修改密码",
                                icon: "PieChart"
                            },
                            component: () => import('@/views/profile/ModifyPwd.vue')
                        },
                        {
                            path: "info",
                            name: "Info",
                            meta: {
                                title: "个人信息",
                                icon: "Histogram"
                            },
                            component: () => import('@/views/profile/Info.vue')
                        }
                    ]
                }


            ] */
            
        },

       
    ]
})
router.beforeEach((to, from, next) => {
    console.log('路由前置导航守卫==', to, from)
    next()

})

>>>>>>> c088509ecc2282a34d0b932f6925d649261c336d
export default router
